/********************************************************************************************************
 * PROGRAM      : TM
 * DATE - TIME  : Friday 04 August 2006 - 19h18
 * AUTHOR       :  (  )
 * FILENAME     : main.cpp
 * LICENSE      : 
 * COMMENTARY   : 
 ********************************************************************************************************/
#include <QCoreApplication>
#include <QtDebug>
#include <signal.h>
#include "mtmlogger.h"
///////////////////Changes, last above//////////////////////
// added Ctrl+C termination handling - writing endfing tag in data file
////////////////////////////////////////////////////////////

MTMLogger *g_tmLogger = NULL;
void cleanUp(int sig)
{
    if(g_tmLogger)
    {
        g_tmLogger->cleanUp();
        exit(0);
    }
    exit(1);
}
int main( int argc, char ** argv )
{
	QCoreApplication app( argc, argv );

    MTMLogger tmLogger;
    g_tmLogger = &tmLogger;
    QObject::connect(&app,SIGNAL(aboutToQuit()),&tmLogger,SLOT(cleanUp()));
    signal(SIGTERM,cleanUp);
    signal(SIGINT, cleanUp);
    signal(SIGQUIT,cleanUp);
    signal(SIGHUP, cleanUp);
	return app.exec();
}
